import os
import socket
import sys

def get_python_path():
    """
    获取python路径
    :return:
    """
    host_name = socket.gethostname()
    if host_name == "legend":
        python_path = "/home/legend/WorkSpace/python/water_applets/"
    if host_name == "ecs-364582":
        python_path = "/root/water_applets/"
    else:
        python_path = ""
    return python_path

sys.path.append(get_python_path())
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "water_applets.settings")
django.setup()
from django.utils import timezone
from models.models import WaterDropletsTask



def set_water_droplets_task_origin_date():
    WaterDropletsTask.objects.all().delete()
    data = [
        {
            "id": 1,
            "task_name": "登录任务",
            "droplet_number": 11,
            "set_time": timezone.now(),
            "on": True
        },
        {
            "id": 2,
            "task_name": "逛一逛商城",
            "droplet_number": 11,
            "set_time": timezone.now(),
            "on": True
        },
        {
            "id": 3,
            "task_name": "添加购物车",
            "droplet_number": 32,
            "set_time": timezone.now(),
            "on": True
        },
        {
            "id": 4,
            "task_name": "购买商品",
            "droplet_number": 12,
            "set_time": timezone.now(),
            "on": True
        },
        {
            "id": 5,
            "task_name": "邀请好友",
            "droplet_number": 55,
            "set_time": timezone.now(),
            "on": True
        }
    ]
    WaterDropletsTask.objects.bulk_create([WaterDropletsTask(**item) for item in data])


if __name__ == '__main__':
    set_water_droplets_task_origin_date()